package com.xx.jenkinsdemo.util;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * @title: ObjectUtil
 * @Author xu-xiang
 * @Date: 2025/7/8 11:23
 * @description:
 */
public class ObjectUtil {
    public static Map<String, Object> objectToMap(Object object) {
        Map<String, Object> map = new HashMap<>();
        for (Field declaredField : object.getClass().getDeclaredFields()) {
            declaredField.setAccessible(true);
            try {
                map.put(declaredField.getName(), declaredField.get(object));
            } catch (IllegalAccessException ignore) {
            }
        }
        return map;
    }
}
